function graphics = gXperceptuomotor_Graphics(varargin)
% Graphics for the perceptuomotor matching task
%   2 dXtextures for color or grating or whatever
%   1 invisible dXtarget
%
%   Get the square side length of each texture (deg. vis angle) from
%   varargin.
%
%   Imagine using a joystick to move a cursor to the target, all within one
%   of the textures.  Also imagine that the X and Y positions of cursor and
%   target correspond to texture properties like colors, spatial frequency,
%   or contrast.  So there's a 1-1 correspondence between spatial movement
%   and perceptual manipulation.
%
%   Then imagine that the cursor and target are invisible, so have only the
%   the perceptual properties of the texture for navigation.  Let one
%   texture represent the perceptual goal or target, and let the other
%   texture represent the perceptual probe or cursor.

% 2008 Benjamin Heasly at University of Pennsylvania.

if nargin
    s = varargin{1};
else
    s = 10;
end

% I'm thinking of a couple of types of texture:
%
%   1. @textureAverageColor, a Gaussian-windowed plain color field.
%   Displays the weighted average color*lum + bgColor*bgLum.
%
%   2. @textureGabor, a Gaussian-windowed cosine grating.  Displays a cos
%   grating with spatial frequency (cycles per deg. vis. angle) given in
%   the textureArgs property, and the given contrast (Michelson?). 
%
%   For both textures, the Gaussian window is in the alpha channel, and
%   has standard deviation (deg. vis. angle) specified in the duration
%   property.
%
%   So during a task, the X and Y positions of somethign like a joystick
%   would get mapped to relevant parameters.  For example,
%       X->lum and Y->bgLum, for the color field, or
%       X->contrast and Y->textureArgs (i.e. frequency) for the Gabor

arg_dXtexture = { ...
    'color',            [255 255 255], ...
    'bgColor',          [0 0 0], ...
    'duration',         s/4, ...
    'lum',              1, ...
    'bgLum',            .5, ...
    'contrast',         .8, ...
    'textureArgs',      .5, ...
    ...'textureFunction',  @textureAverageColor, ...
    'textureFunction',  @textureGabor, ...
    'x',                {-(s/2+1), s/2+1}, ...
    'y',                0, ...
    'w',                s, ...
    'h',                s, ...
    'filterMode',       1, ...
    'preload',          true, ...
    'visible',          true, ...
    };

arg_dXtarget = { ...
    'x',                s/2+1, ...
    'visible',          false, ...
    };

static = {'root', true, true, false};
graphics = { ...
    'dXtexture',    2,  static, arg_dXtexture; ...
    'dXtarget',     1,  static, arg_dXtarget; ...
    };